package service

import (
	"context"
	"github.com/aphasia51/website/internal/domain"
	"github.com/aphasia51/website/internal/repository"
)

type AccidentService struct {
	repo *repository.AccidentRepository
}

func NewAccidentService(repo *repository.AccidentRepository) *AccidentService {
	return &AccidentService{
		repo: repo,
	}
}

func (svc *AccidentService) Create(ctx context.Context, a domain.Accident) (int64, error) {
	return svc.repo.Create(ctx, a)
}

func (svc *AccidentService) Query(ctx context.Context, a domain.AccidentSearchParam) ([]domain.Accident, error) {
	return svc.repo.Query(ctx, a)
}

func (svc *AccidentService) Delete(ctx context.Context, ids []string) (int64, error) {
	return svc.repo.Delete(ctx, ids)
}

func (svc *AccidentService) QueryRelatedItem(ctx context.Context, id string) (domain.AccidentItems, error) {
	return svc.repo.QueryRelatedItem(ctx, id)
}

func (svc *AccidentService) UpdateRelatedItem(ctx context.Context, accidentId string, itemType string, items []string) (int64, error) {
	return svc.repo.UpdateRelatedItem(ctx, accidentId, itemType, items)
}

func (svc *AccidentService) QueryItemAll(ctx context.Context, accident_id string, item_type string) ([]domain.TreeItem, error) {
	return svc.repo.QueryItemAll(ctx, accident_id, item_type)
}
